package com.lty.jeeg.server.modules.tms.controller;

import com.lty.jeeg.server.common.dto.ResponseInfo;
import com.lty.jeeg.server.common.utils.ResponseUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lty.jeeg.server.common.page.table.PageTableRequest;
import com.lty.jeeg.server.common.page.table.PageTableResponse;

import com.lty.jeeg.server.modules.tms.model.TaskAtUsers;
import com.lty.jeeg.server.modules.tms.service.TaskAtUsersService;

import io.swagger.annotations.ApiOperation;

/**
 * @author : LTY
 * @date : 2019-04-09 14:34:25
 * Description : 任务At用户表
 */
@Api(tags = "任务At用户表")
@RestController
@RequestMapping("/taskAtUsers")
public class TaskAtUsersController {

    private final TaskAtUsersService taskAtUsersService;

    @Autowired
    public TaskAtUsersController(TaskAtUsersService taskAtUsersService) {
        this.taskAtUsersService = taskAtUsersService;
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据id获取")
    public ResponseInfo get(@PathVariable Long id) {
        return ResponseUtil.success(taskAtUsersService.getById(id));
    }

    @PostMapping
    @ApiOperation(value = "保存")
    public ResponseInfo save(@RequestBody TaskAtUsers taskAtUsers) {
        return ResponseUtil.success(taskAtUsersService.save(taskAtUsers));
    }

    @PutMapping
    @ApiOperation(value = "修改")
    public ResponseInfo update(@RequestBody TaskAtUsers taskAtUsers) {
        return ResponseUtil.success(taskAtUsersService.update(taskAtUsers));
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除")
    public ResponseInfo delete(@PathVariable Long id) {
        return ResponseUtil.success(taskAtUsersService.delete(id));
    }

    @GetMapping("/list")
    @ApiOperation(value = "列表")
    public PageTableResponse list(PageTableRequest request) {
        return taskAtUsersService.list(request);
    }

}
